public class PrintingResultHandler extends java.lang.Object implements ResultHandler
MvcResult
details to a given output
stream — for example: System.out
, System.err
, a
custom java.io.PrintWriter
, etc.
An instance of this class is typically accessed via one of the
print
or log
methods in MockMvcResultHandlers
.
Modifier and Type | Class and Description |
---|---|
protected static interface |
PrintingResultHandler.ResultValuePrinter
A contract for how to actually write result information.
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
MISSING_CHARACTER_ENCODING |
private PrintingResultHandler.ResultValuePrinter |
printer |
Modifier | Constructor and Description |
---|---|
protected |
PrintingResultHandler(PrintingResultHandler.ResultValuePrinter printer)
Protected constructor.
|
Modifier and Type | Method and Description |
---|---|
protected MultiValueMap<java.lang.String,java.lang.String> |
getParamsMultiValueMap(MockHttpServletRequest request) |
protected PrintingResultHandler.ResultValuePrinter |
getPrinter() |
protected HttpHeaders |
getRequestHeaders(MockHttpServletRequest request) |
protected HttpHeaders |
getResponseHeaders(MockHttpServletResponse response) |
protected java.util.Map<java.lang.String,java.lang.Object> |
getSessionAttributes(MockHttpServletRequest request) |
void |
handle(MvcResult result)
Print
MvcResult details. |
protected void |
printAsyncResult(MvcResult result) |
private void |
printCookies(Cookie[] cookies)
Print the supplied cookies in a human-readable form, assuming the
Cookie implementation does not provide its own toString() . |
protected void |
printFlashMap(FlashMap flashMap)
Print "output" flash attributes.
|
protected void |
printHandler(java.lang.Object handler,
HandlerInterceptor[] interceptors)
Print the handler.
|
protected void |
printModelAndView(ModelAndView mav)
Print the ModelAndView.
|
protected void |
printRequest(MockHttpServletRequest request)
Print the request.
|
protected void |
printResolvedException(java.lang.Exception resolvedException)
Print exceptions resolved through a HandlerExceptionResolver.
|
protected void |
printResponse(MockHttpServletResponse response)
Print the response.
|
private static final java.lang.String MISSING_CHARACTER_ENCODING
private final PrintingResultHandler.ResultValuePrinter printer
protected PrintingResultHandler(PrintingResultHandler.ResultValuePrinter printer)
printer
- a PrintingResultHandler.ResultValuePrinter
to do the actual writingprotected PrintingResultHandler.ResultValuePrinter getPrinter()
public final void handle(MvcResult result) throws java.lang.Exception
MvcResult
details.handle
in interface ResultHandler
result
- the result of the executed requestjava.lang.Exception
- if a failure occursprotected void printRequest(MockHttpServletRequest request) throws java.lang.Exception
java.lang.Exception
protected final HttpHeaders getRequestHeaders(MockHttpServletRequest request)
protected final MultiValueMap<java.lang.String,java.lang.String> getParamsMultiValueMap(MockHttpServletRequest request)
protected final java.util.Map<java.lang.String,java.lang.Object> getSessionAttributes(MockHttpServletRequest request)
protected void printAsyncResult(MvcResult result) throws java.lang.Exception
java.lang.Exception
protected void printHandler(@Nullable java.lang.Object handler, @Nullable HandlerInterceptor[] interceptors) throws java.lang.Exception
java.lang.Exception
protected void printResolvedException(@Nullable java.lang.Exception resolvedException) throws java.lang.Exception
java.lang.Exception
protected void printModelAndView(@Nullable ModelAndView mav) throws java.lang.Exception
java.lang.Exception
protected void printFlashMap(FlashMap flashMap) throws java.lang.Exception
java.lang.Exception
protected void printResponse(MockHttpServletResponse response) throws java.lang.Exception
java.lang.Exception
private void printCookies(Cookie[] cookies)
Cookie
implementation does not provide its own toString()
.protected final HttpHeaders getResponseHeaders(MockHttpServletResponse response)